package com.ysstech.reportworld.enums;

import com.ysstech.common.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 系统常量
 *
 * @author lsl
 */
@Getter
@AllArgsConstructor
public enum ReportWorldEnum implements BaseEnum<String> {
    REPORT_TABLE_LAYERED("REPORT_TABLE_LAYERED", "报表世界所在分层"),
    REPORT_TABLE_FTYPE("REPORT_TABLE_FTYPE", "报表世界表类型"),
    REPORT_TABLE_FSOURCE("REPORT_TABLE_FSOURCE", "报表世界表来源"),
    REPORT_TABLE_INDEXED("REPORT_TABLE_INDEXED", "报表世界表索引类型"),
    REPORT_DATABASE_TYPE("REPORT_DATABASE_TYPE", "数据库来源"),
    COLUMN_TYPE("COLUMN_TYPE", "字段类型字典值"),
    REPORT_MODULAR("REPORT_MODULAR", "模块信息的缓存key"),
    REPORT_CUSTOMER("REPORT_CUSTOMER", "客户信息的缓存key"),
    REPORT_REPORT("REPORT_REPORT", "报表信息的缓存key"),
    DATASQL("DATASQL", "SQL类型"),
    REPORT_VERSION("REPORT_VERSION", "报表世界版本号"),
    REPORT_STATUS("REPORT_STATUS", "报表表状态"),
    REPORT_DATASQL_CODE("REPORT_DATASQL_CODE", "SQL的数据编码"),
    REPORT_TABLE_CODE("REPORT_TABLE_CODE", "表结构的数据编码"),
    REPORT_TABLE_DETAIL_CODE("REPORT_TABLE_DETAIL_CODE", "表结构明细的数据编码"),
    REPORT_SQLSCRIPT_CODE("REPORT_SQLSCRIPT_CODE", "脚本对应的编码"),
    USERNAME("USERNAME", "admin"),
    PASSWORD("PASSWORD", "qwe1234!"),
    ADD_WECOM_URL("ADD_WECOM_URL", "企业微信机器人地址!");;

    private final String code;
    private final String desc;

    public static ReportWorldEnum getEnum(String code) {
        return Arrays.stream(values()).filter(b -> Objects.equals(b.code, code)).findFirst().orElse(null);
    }

    public static String getEnumDesc(String code) {
        ReportWorldEnum e = getEnum(code);
        return e != null ? e.desc : null;
    }
}
